@include('admin.layout.css')
@include('admin.layout.js')




<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">


    <div class="layui-form-item">
        <label class="layui-form-label">项目分类</label>
        <div class="layui-input-block">
            @foreach($categorys as $value)
                <input type="radio" name="category_id" value="{{$value['category_id']}}" title="{{$value['category_name']}}" >
            @endforeach
        </div>
    </div>


{{--    <div class="layui-form-item">--}}
{{--        <label class="layui-form-label">项目类型</label>--}}
{{--        <div class="layui-input-block">--}}
{{--            <input type="radio" name="product_type" value="0" title="普通" >--}}
{{--            <input type="radio" name="product_type" value="1" title="VIP展示" >--}}
{{--        </div>--}}
{{--    </div>--}}




    <div class="layui-form-item">
        <label class="layui-form-label">项目封面</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="test1">上传图片</button>
            <input type="hidden" name="project_image_project_view_url" id="img_url">
            <div class="layui-upload-list" >
                <img class="layui-upload-img"  id="img_url_show" width="92px" height="92px">
                <p id="demoText"></p>
            </div>
        </div>
    </div>




    <div class="layui-form-item">
        <label class="layui-form-label">项目视频</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="test2">上传视频</button>
            <input type="hidden" name="project_view_url" id="img_url1">
            <div class="layui-upload-list" >
                <a href="" id="img_url_show1" target="_blank">查看视频</a>

                <p id="demoText"></p>
            </div>
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">项目名称</label>
        <div class="layui-input-block">
            <input type="text"  name="project_name"  placeholder="请输入项目名称" autocomplete="off" class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">项目价格</label>
        <div class="layui-input-block">
            <input type="text"  name="project_price"  placeholder="请输入项目价格" autocomplete="off" class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">会员等级(1普通代理2高级代理)</label>
        <div class="layui-input-block">
            <input type="text"  name="vip_level_index"  placeholder="请输入会员等级" autocomplete="off" class="layui-input" >
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">项目销量</label>
        <div class="layui-input-inline">
            <input type="text"  name="xiaoliang"  placeholder="请输入项目销量" autocomplete="off" class="layui-input" >
        </div>

        <label class="layui-form-label">项目阅读</label>
        <div class="layui-input-inline">
            <input type="text"  name="show_nums"  placeholder="请输入项目阅读" autocomplete="off" class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">(直推奖)</label>
        <div class="layui-input-inline">
            <input type="text"  name="project_price_spread"  placeholder="直推奖" autocomplete="off" class="layui-input" >
        </div>

        <label class="layui-form-label">(见点奖)</label>
        <div class="layui-input-inline">
            <input type="text"  name="project_zongjian_price"  placeholder="见点奖" autocomplete="off" class="layui-input" >
        </div>
    </div>













    <div class="layui-form-item">
        <label class="layui-form-label">项目说明文字</label>
        <div class="layui-input-block">
            <textarea name="project_text_info" rows="10" cols="30"></textarea>
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">项目图片介绍</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="test3">上传图片</button>
            <input type="hidden" name="project_imgs" id="img_url3">
            <div class="layui-upload-list" >
                <img class="layui-upload-img"  id="img_url_show3" width="92px" height="92px">
                <p id="demoText"></p>
            </div>
        </div>
    </div>



    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="submit" id="submit" value="确认">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="取消">
    </div>

</div>


<script>

    UI.upload('#test1',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show').attr('src',res['data']['src']);
            $('#img_url').val(res['data']['src']);
        }
    });

    UI.upload('#test2',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show1').attr('href',res['data']['src']);
            $('#img_url1').val(res['data']['src']);
        }
    },'video');

    UI.upload('#test3',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show3').attr('src',res['data']['src']);
            $('#img_url3').val(res['data']['src']);
        }
    });

    layui.use(['laydate','form'], function() {
        let form = layui.form;
        form.on('submit(submit)', function(data){

            Api.add("{{route('admin.xiangmu.add_project')}}",data.field,function(res){
                if (res.code !== 200){
                    Utils.errorToast(res.msg);
                    return;
                }
            });
        });


    });
</script>
